package com.realone.packman.codec.decoder;

import com.realone.packman.codec.decoder.vo.BmsDecoderDataVo1d;
import com.realone.packman.codec.exception.BmsDecoderException;

import java.nio.ByteBuffer;

/**
 * 获取BMS系统参数 解码
 *
 * @author hugx
 * @create 2018-09-18 15:16
 */
public class BmsDecoder1d extends BmsDecoder<BmsDecoderDataVo1d> implements BmsDecoderStrategy {


    public BmsDecoder1d(Integer classType) {
        super.classType = classType;
    }

    @Override
    public BmsDecoderDataVo1d decoderBody(ByteBuffer bb) {
        if (bb == null) {
            throw new BmsDecoderException(new NullPointerException());
        }

        BmsDecoderDataVo1d result = new BmsDecoderDataVo1d(super.classType);
        result.setHighTemperatureThreshold(bb.get());
        result.setLowTemperatureThreshold(bb.get());
        result.setHighHumidityThreshold(bb.get());

        return result;
    }


}
